import { createStore, applyMiddleware } from 'redux'
import promise from 'redux-promise'
import thunk from 'redux-thunk'

import { persistReducer } from 'redux-persist'
import { composeWithDevTools } from 'redux-devtools-extension'
import storage from 'redux-persist/lib/storage'

import reducers from '@/models'

const reducer = persistReducer(
  {
    key: 'root',
    storage: storage,
  },
  reducers
)

const middleware = composeWithDevTools(applyMiddleware(promise, thunk))
const store = createStore(reducer, middleware)
export default store
